package com.zhuannimei.parser;

import java.util.UUID;

import org.json.JSONException;
import org.json.JSONObject;

import com.zhuannimei.domain.ZnmMessage;

public class MessageParser extends BaseJSONParser<ZnmMessage> {
	@Override
	public ZnmMessage parseJSON(String jsonstr) throws JSONException {
		ZnmMessage off = new ZnmMessage();
		JSONObject jo = new JSONObject(jsonstr);
		off.setId(UUID.randomUUID()+"");
		off.setTime(jo.optString("time"));
		off.setType(jo.optString("type"));
		off.setContent(jo.optString("content"));
		JSONObject joo = jo.getJSONObject("ext");
		off.setCgyId(joo.optString("cgyId"));
		off.setPhase(joo.optString("phase"));
		return off;
	}


}
